<template>
  <x-back class="certification-page">
    <template #header>
      <label>{{ $t('certification.myEnterprise.title') }}</label>
      <div class="title-btn">
        <el-button @click="handleCancel"> {{ $t('common.cancel') }} </el-button>
        <el-button v-hasPermi="['srm:supplierInfo:applyChange']" type="primary" @click="handleChangeInfo()">
          {{ $t('certification.myEnterprise.applyChange') }}
        </el-button>
      </div>
    </template>
    <div class="main-panel">
      <supplier-information ref="supplierInformationCom" :supplierInfo="auditInfo"></supplier-information>
    </div>
  </x-back>
</template>
<script>
  import SupplierInformation from '@package/components/src/workflow/components/workFlowForm/supplierInformation/index.vue'
  import { QueryDictMixin, throttle } from '@package/utils'

  import { mapState } from 'pinia'
  import { stepList } from '../config/certification'
  import { pinias } from '@/common/pinia'

  const { login } = pinias
  export default {
    name: 'MyEnterprise',
    components: {
      SupplierInformation
    },
    mixins: [QueryDictMixin],
    data() {
      return {
        stepList,
        dictKeys: ['system.whether'],
        srmDictKeys: [
          'bank_category',
          'shareholder_type',
          'certificate_type',
          'srm_supplier_info.qualification_category',
          'srm_supplier_info.economic_type',
          'srm_supplier_info.enterprise_type',
          'currency',
          'srm_supplier_info.enterprise_attribute',
          'srm_supplier_info.nature',
          'srm_supplier_info.source',
          'srm_supplier_info.audit_state'
          // ''
        ]
      }
    },
    computed: {
      ...mapState(login, ['supplierId', 'auditState', 'auditInfo'])
    },
    created() {
      this.initDictConfig()
    },
    methods: {
      handleChangeInfo: throttle(function () {
        this.$router.push({
          path: '/enterpriseInfoModify',
          query: {
            edit: this.auditState !== 2
          }
        })
      }, 1000),
      handleCancel() {
        this.$router.push({
          path: '/home'
        })
      }
    }
  }
</script>
<style lang="scss" scope>
  @import '../style/index.scss';
</style>
<style lang="scss" scoped>
  .main-panel {
    display: flex;
    overflow: hidden;
    .flow-form {
      flex: 1;
    }
  }
</style>
